package org.example.spring_book.enums;

/**
 * @ClassName BookStateEnums
 * @Description TODO
 * @Author wangxiaodong
 */
public enum BookStateEnums {
    DELETED(0,"⽆效"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅");
    private int code;
    private String desc;

    BookStateEnums(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static BookStateEnums getDescByCode(int code){
        switch (code){
            case 0: return BookStateEnums.DELETED;
            case 1: return BookStateEnums.NORMAL;
            case 2: return BookStateEnums.FORBIDDEN;
        }
        return BookStateEnums.DELETED;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
